package ie.dpsystems.errorlog;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class BasicErrorDetailListAdapter extends ArrayAdapter<ErrorBasicDetails> {
	
	private final Activity _activity;
	private final List<ErrorBasicDetails> _values;
	  public BasicErrorDetailListAdapter(Activity activity, List<ErrorBasicDetails> values) {
		super(activity, android.R.layout.simple_list_item_1, values);
		this._activity = activity;
	    this._values = values;
	}

	  @Override
	  public View getView(int position, View convertView, ViewGroup parent) {
	    LayoutInflater inflater = (LayoutInflater) _activity
	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    View rowView = inflater.inflate(R.layout.error_list_item_activity, parent, false);
	    TextView date = (TextView)rowView.findViewById(R.id.error_log_date_sum);
	    TextView windowsUser = (TextView)rowView.findViewById(R.id.error_windows_user_sum);
	    TextView callStack = (TextView)rowView.findViewById(R.id.error_call_stack_sum);
	    TextView additionalData = (TextView)rowView.findViewById(R.id.error_additional_info);
	    
	    ErrorBasicDetails element = _values.get(position);
		date.setText(element.GetDateWithFormat());
		windowsUser.setText(element.get_windowsUserName());
		callStack.setText(element.get_callStack());
		additionalData.setText(element.get_message());
		
	    return rowView;
	  }
	}